package com.loup.handler;

import java.sql.PreparedStatement;
import java.util.HashMap;
import java.util.Map;

/**
 * java对象和数据库字段的映射关系处理
 * Created by loup on 2018/4/28.
 */
public class SimpleTypeHandler implements TypeHandler {

    private static Map<String, Map<String, String>> typeMataMap = new HashMap<String, Map<String, String>>();

    public static Map<String, String> getPropertyClounmMapper(String classPathName) {
        return typeMataMap.get(classPathName);
    }

    /**
     * 添加字段映射关系
     * @param classPathName
     * @param porperty
     * @param column
     */
    public void addPorpertyColumsMapper(String classPathName, String porperty, String column) {
        Map<String, String> proportyColumnMapper = typeMataMap.get(classPathName);
        if (proportyColumnMapper == null) {
            proportyColumnMapper = new HashMap<String, String>();
        }
        proportyColumnMapper.put(porperty, column);
        typeMataMap.put(classPathName, proportyColumnMapper);
    }

    public void setParameter(PreparedStatement ps, int i, Object value) {
        System.out.println();
    }

    public static class TypeMata {

        private Map<String, String> propertyColum = new HashMap<String, String>();
        private String preprty;

        private String cloumn;

        public TypeMata(String proporty, String column) {
            this.preprty = proporty;
            this.cloumn = cloumn;
        }
    }

    public void setAAA(){
        System.out.println("sssdfdasfas");
    }
}
